// 1.匿名函数
let f = () => '1';
console.log(f());

let f1 = function () {
    return 'function';
}
console.log(f1());

//2.默认参数值,可选参数放在最后
let f3 = (name: string = "Jack", index?: number) => {
    // name="Tom";
    index = 100;
    return `${name} is ${index} years old`;
};
console.log(f3('Tom'));

//2.默
let f2 = (name: string = "Jack", index: number) => {
    // name="Tom";
    return `${name} is ${index} years old`;
};
// console.log(f2('Tom')); //error
console.log(f2('Tom', 101));

//4三点参数 实用参数
let f4 = (...index: number[]) => {
    let sum = 0;
    for (let i = 0; i < index.length; i++) {
        sum += index[i];
    }
    return sum;
};

/*可以传递多个参数*/
console.log(f4(1, 2, 3, 4, 5, 6));

//5.方法重载

// function fs(): void {
//     console.log('reload');
// }
//
// function fs(index: number = 10): number {
//     return index;
// }
//
// fs();
//
// console.log(fs(1));
